import { lazy } from "react"
import { createBrowserRouter, Navigate } from "react-router"

const Home = lazy(() => import("@/views/home"))
const Chat = lazy(() => import("@/views/home/chat"))
const Search = lazy(() => import("@/views/home/search"))
const Login = lazy(() => import("@/views/login"))

const router = createBrowserRouter([
  {
    path: "/",
    element: <Home />,
    children: [
      { index: true, element: <Navigate to="/chat" /> },
      { path: "/chat/:id?", element: <Chat /> },
      { path: "/chat/search", element: <Search /> }
    ]
  },
  {
    path: "/login",
    element: <Login />
  }
])

export default router
